package io.xccit.common.utils;


import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * @author ywx
 * @version 1.0
 * @create 2025/7/16
 * <p>文件路径构造</p>
 */
public class FilePathUtil {

    /**
     * 生成包含当前日期和文件名的对象路径
     *
     * @param fileName 文件名
     * @return 生成的对象路径
     */
    public static String generateObjectPath(String fileName) {
        // 获取当前日期
        LocalDate currentDate = LocalDate.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
        String formattedDate = currentDate.format(formatter);
        return Paths.get(formattedDate, fileName).toString();
    }

    public static void main(String[] args) {
        String fileName = "example.txt";
        String objectPath = generateObjectPath(fileName);
        System.out.println("Generated object path: " + objectPath);
    }
}
